import { defineStore } from "pinia";
import { ref } from "vue";
import { https } from "@/api/api";
import staffData from '@/public/data'
import { showToast } from "@/public";
const useTeamStore = defineStore("teamStore", () => {
  // 记录业务经理id
  const managerId = ref<string>("");
  // 团队id
  const teamId = ref<string>();
  // 记录员工ID
  const staffId = ref<string>();
  // 记录要查看的时间
  const recordTime=ref<string>('');
  // 获取员工列表
  const apiStaffList = async () => {
    const res = await https({
      mode: "team",
      name: "apiStaffList",
      data: {
        team: String(teamId.value),
      },
    });
    if(res.code!==0) showToast(res.data.msg)
    return res
  };
  // 获取团队列表
  const apiTeamList = async () => {
    const res = await https({
      mode: "team",
      name: "apiGetTeamList",
      data: {
        manager: managerId.value,
      },
    });
    return res;
  };
  //   获取业务经理列表
  const apiManagerList = async () => {
    const res = await https({
      mode: "team",
      name: "apiGetManagerList",
    });
    return res
  };
  //   设置业务经理id
  const setManagerId = (id: string) => {
    managerId.value = id;
  };
  // 设置团队id
  const setTeamId = (id: string) => {
    teamId.value = id;
  };
  return {
    managerId,
    teamId,
    staffId,
    recordTime,
    apiTeamList,
    apiManagerList,
    setManagerId,
    setTeamId,
    apiStaffList
  };
});
export default useTeamStore;
